#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {

        int sum=0;
        int n;
        cin>>n;
        int a[100005]{};
        for(int i=0;i<n;i++)
        {
            cin>>a[i];

        }
       sort(a,a+n);
       for(int i=0;i<n;i++)
       {
           if(a[i]==a[i-1])
             sum=sum+a[i];
       }
       cout<<sum;
    }
    return 0;
}
